//
// Created by wxd on 2025/7/20.
//

#pragma once

#include <iomanip>
#include <iostream>
#include <sstream>
#include <vector>
#include <glm/glm.hpp>
#include <string>

#define OUTPUT_PLACEHOLDER_WIDTH 10
#define OUTPUT_PRECISION 6

namespace EngineOutput {
    template<typename T>
    void outputVector(const std::string& tag, const std::vector<T>& v) {
        if (v.empty()) return;

        std::ostringstream oss;
        oss << tag << ": \n";
        oss << "[";
        for (const auto it : v) oss << std::setw(OUTPUT_PLACEHOLDER_WIDTH) << it << ", ";
        oss << "]";

        std::cout << oss.str() << "\n";
    }

    inline void outputMatrix(const std::string& tag, const glm::mat4& mat) {
        if (mat.length() == 0) return;

        std::cout << std::fixed << std::setprecision(OUTPUT_PRECISION);

        std::ostringstream oss;
        oss << tag << ": \n";
        for (int i = 0; i < 4; i++) {
            oss << "[";
            for (int j = 0; j < 4; j++) {
                if (j < 3) {
                    oss << std::setw(OUTPUT_PLACEHOLDER_WIDTH) << mat[j][i] << ", ";
                } else {
                    oss << std::setw(OUTPUT_PLACEHOLDER_WIDTH) << mat[j][i];
                }
            }
            oss << "]\n";
        }
        std::cout << oss.str() << "\n";
    }
}